package util;

import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Locale;
import java.util.ResourceBundle;

import bundles.BundleLoader;
import definitions.Constants;
import entities.Address;

/**
 * Helper Class to deliver Data for Combo Boxes
 * 
 * @author MK
 * 
 */
public class ValuesForComboBoxes {

	public static ValueStringPair[] getMonthValues() {

		DateFormatSymbols dfs = new DateFormatSymbols(Locale.getDefault());

		ValueStringPair[] monthValues = new ValueStringPair[12];
		for (int monthCounter = 0; monthCounter < 12; monthCounter++) {
			monthValues[monthCounter] = new ValueStringPair(monthCounter, dfs
					.getMonths()[monthCounter]);
		}
		return monthValues;
	}

	public static String[] getDaysOfMonthValues() {

		String[] dayBoxValues = new String[31];
		for (int dayCounter = 0; dayCounter <= 30; dayCounter++) {
			dayBoxValues[dayCounter] = "" + (dayCounter + 1);
		}
		return dayBoxValues;
	}

	public static StringStringPair[] getStateValues() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();

		StringStringPair[] stateValues = new StringStringPair[5];
		stateValues[0] = new StringStringPair(Constants.STATE_HEALTHY,
				resBundle.getString(Constants.STATE_HEALTHY));
		stateValues[1] = new StringStringPair(Constants.STATE_INJURED,
				resBundle.getString(Constants.STATE_INJURED));
		stateValues[2] = new StringStringPair(Constants.STATE_SUSPENDED,
				resBundle.getString(Constants.STATE_SUSPENDED));
		stateValues[3] = new StringStringPair(Constants.STATE_VACATIONED,
				resBundle.getString(Constants.STATE_VACATIONED));
		stateValues[4] = new StringStringPair(Constants.STATE_OTHER, resBundle
				.getString(Constants.STATE_OTHER));

		return stateValues;
	}

	public static StringStringPair[] getPositionValues() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();

		StringStringPair[] positionValues = new StringStringPair[4];
		positionValues[0] = new StringStringPair(Constants.POSITION_GOALKEEPER,
				resBundle.getString(Constants.POSITION_GOALKEEPER));
		positionValues[1] = new StringStringPair(Constants.POSITION_DEFENDER,
				resBundle.getString(Constants.POSITION_DEFENDER));
		positionValues[2] = new StringStringPair(Constants.POSITION_MIDFIELDER,
				resBundle.getString(Constants.POSITION_MIDFIELDER));
		positionValues[3] = new StringStringPair(Constants.POSITION_STRIKER,
				resBundle.getString(Constants.POSITION_STRIKER));

		return positionValues;
	}

	public static StringStringPair[] getRoleValues() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();

		StringStringPair[] roleValues = new StringStringPair[2];
		roleValues[0] = new StringStringPair(Constants.ROLE_PLAYER, resBundle
				.getString(Constants.ROLE_PLAYER));
		roleValues[1] = new StringStringPair(Constants.ROLE_COACH, resBundle
				.getString(Constants.ROLE_COACH));

		return roleValues;
	}

	public static String[] getTrainingDaysValues() {

		String[] trainingDaysValues = new String[5];
		for (int trainingDaysCounter = 0; trainingDaysCounter < 5; trainingDaysCounter++) {
			trainingDaysValues[trainingDaysCounter] = ""
					+ (trainingDaysCounter + 1);
		}
		return trainingDaysValues;
	}

	public static ValueStringPair[] getWeekdaysValues() {

		DateFormatSymbols dfs = new DateFormatSymbols(Locale.getDefault());
		ValueStringPair[] weekdaysValues = new ValueStringPair[7];
		weekdaysValues[0] = new ValueStringPair(2, dfs.getWeekdays()[2]);
		weekdaysValues[1] = new ValueStringPair(3, dfs.getWeekdays()[3]);
		weekdaysValues[2] = new ValueStringPair(4, dfs.getWeekdays()[4]);
		weekdaysValues[3] = new ValueStringPair(5, dfs.getWeekdays()[5]);
		weekdaysValues[4] = new ValueStringPair(6, dfs.getWeekdays()[6]);
		weekdaysValues[5] = new ValueStringPair(7, dfs.getWeekdays()[7]);
		weekdaysValues[6] = new ValueStringPair(1, dfs.getWeekdays()[1]);
		return weekdaysValues;
	}

	public static ValueStringPair[] getTimeValues() {
		ValueStringPair[] timeValues = new ValueStringPair[11];
		for (int timeCounter = 0; timeCounter < timeValues.length; timeCounter++) {
			timeValues[timeCounter] = new ValueStringPair(timeCounter + 10, ""
					+ (timeCounter + 10) + ":00 Uhr");
		}
		return timeValues;
	}

	public static String[] getAddressValues() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();

		ArrayList<Address> addresses = DBFunctions.getAddressesWithIdentifier();

		String[] addressesAsArray = new String[addresses.size() + 1];

		addressesAsArray[0] = resBundle.getString("newAddress");

		for (int counter = 1; counter < addressesAsArray.length; counter++) {
			addressesAsArray[counter] = addresses.get(counter - 1)
					.getIdentifier();
		}
		return addressesAsArray;
	}

	public static ValueStringPair[] getRatingValues() {
		ValueStringPair[] ratingValues = new ValueStringPair[7];

		ratingValues[0] = new ValueStringPair(0, "---");

		for (int ratingCounter = 1; ratingCounter < ratingValues.length; ratingCounter++) {
			ratingValues[ratingCounter] = new ValueStringPair(ratingCounter, ""
					+ ratingCounter);
		}
		return ratingValues;
	}

	public static StringStringPair[] getStatsDescriptionValues() {

		ResourceBundle resBundle = BundleLoader.getResourceBundle();

		StringStringPair[] ssp = new StringStringPair[2];

		ssp[0] = new StringStringPair(Constants.STAT_ATTENDANCE_OVERVIEW,
				resBundle.getString("statAttendance"));
		ssp[1] = new StringStringPair(Constants.STAT_RATING_AVERAGE_OVERVIEW,
				resBundle.getString("statRating"));
		return ssp;
	}
}